﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace 打印1到100
{
    class Program
    {
        static int outNum = 1;
        static int statuNum = 1;

        static void Main(string[] args)
        {
            Thread th1 = new Thread(t1);
            th1.IsBackground = true;
            th1.Start("1");

            Thread th2 = new Thread(t1);
            th2.IsBackground = true;
            th2.Start("2");

            Thread th3 = new Thread(t1);
            th3.IsBackground = true;
            th3.Start("0");

            Thread.Sleep(10);

            while (th1.IsAlive == true || th2.IsAlive == true || th3.IsAlive == true) Thread.Sleep(10);
            Console.WriteLine("程序结束！");

            Console.ReadKey();
        }


        static void t1(object obj)
        {
            string str = obj as string;
            int num = Convert.ToInt32(str);
            while(outNum <=100 )
            {
                if (statuNum != num) continue;
                if (outNum > 100) continue;
                if(num == 0)
                    Console.WriteLine("T3:" + outNum.ToString());
                else
                    Console.WriteLine("T" + str + ":" + outNum.ToString());
                outNum++;
                statuNum = outNum % 3;
            }
        }

    }
}
